package com.loveyukari.utils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.loveyukari.model.Auth;

/**
*
*yangshaohua
*2017年7月31日上午11:08:18
**/
public class AuthUtils {

	
	public static List<Auth> sortAuthByLv(Collection<Auth> collection){
		ArrayList<Auth> reuslt = new ArrayList<Auth>();
		for (Auth auth : collection) {
			if (reuslt.isEmpty()){
				reuslt.add(auth);
			} else {
				for (int i = 0; i < reuslt.size(); i++) {
					if (auth.getLv() <= reuslt.get(i).getLv()){
						reuslt.add(i, auth);
					}
				}
			}
		}
		return reuslt;
	}
	public static List<Auth> sortAuthByLvDesc(Collection<Auth> collection){
		ArrayList<Auth> reuslt = new ArrayList<Auth>();
		for (Auth auth : collection) {
			if (reuslt.isEmpty()){
				reuslt.add(auth);
			} else {
				for (int i = 0; i < reuslt.size(); i++) {
					if (auth.getLv() >= reuslt.get(i).getLv()){
						reuslt.add(i, auth);
					}
				}
			}
		}
		return reuslt;
	}
	
	
}
